$(function () {
    initPersonModal();
});
/**初始化分组**/
function initPersonModal(){
    $.post(ctx+"SaleHelp/getModalGrouplist",{cSaleMtype:1},function (r) {
        if (r.code == 0){
            var data  = r.msg;
            $("#selectPersonModal").empty();
            $.each(data,function (index,val) {
                $("#selectPersonModal").append("<option value='"+val.cSaleUuid+"'>"+val.cSaleTitle+"</option>");
            });
        }else{
            $JuXue.n_danger("初始化个人分组失败");
        }
    });
}

/**保存个人模板**/
function savePersonModal() {
    var title = $("#personModalname").val();
    if (title == ""){$JuXue.n_danger("请填写模板名称");return;}
    var length = title.length;
    if (length > 8 ){$JuXue.n_danger("输入的名称过长");return;}

    var parentid = $("#selectPersonModal").val();
    if (parentid == ""){$JuXue.n_danger("请选择分组");return;}

    $.post(ctx+"SaleHelp/addModalGroup",{"cSaleGroup":parentid,"cSaleTitle":title,"cSaleMtype":1},function (r) {
        if (r.code == 0){
            $JuXue.n_success("新建个人模板成功");
            init_modal("acage","");
            $("#sale_help_one").empty().modal('hide');
        }else{
            $JuXue.n_danger("新建个人模板失败");
        }
    });

}